<script setup>
defineProps({
  list: {
    type: Array,
    default: () => []
  }
})
const emits = defineEmits(['setDone', 'delList'])
const changeEvent = id => {
  emits('setDone', id)
}
</script>

<template>
  <section class="main">
    <input id="toggle-all" class="toggle-all" type="checkbox" />
    <label for="toggle-all">Mark all as complete</label>
    <ul class="todo-list">
      <li :class="{ completed: item.done }" v-for="item in list" :key="item.id">
        <div class="view">
          <input
            @change="changeEvent(item.id)"
            class="toggle"
            type="checkbox"
            :checked="item.done"
          />
          <label>{{ item.name }}</label>
          <button class="destroy" @click="emits('delList', item.id)"></button>
        </div>
        <input class="edit" value="Create a TodoMVC template" />
      </li>
    </ul>
  </section>
</template>

<style lang="less" scoped></style>
